<?php
include("funciones/setup.php");
conecta();

session_start();
if(isset($_SESSION['sesion_usuario']))
{
	$id=$_GET['id'];
	
	if(isset($id))
	{
	$sql="SELECT   pagos.id_pago, pagos.id_factura, factura.id_factura,   factura.id_proveedor, proveedor.id_pro, proveedor.nombre_pro,   cheques.*, cheques.id_cheque, factura.n_factura, factura.*,   pagos.* , cheques.estado  cheques_estado ";
	$sql.=" FROM    cheques INNER JOIN   pagos ON pagos.id_pago = cheques.id_pago INNER JOIN   factura ON factura.id_factura = pagos.id_factura INNER JOIN   proveedor ON proveedor.id_pro = factura.id_proveedor ";
	$sql.=" WHERE   cheques.id_cheque = ".$id; 
	
	$reg=mysql_query($sql);
	$datos=mysql_fetch_array($reg);
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Modulo de Cheques</title>
<link href="css/estilos_forms.css" rel="stylesheet" type="text/css" />
<link href="css/kendo.common.css" rel="stylesheet"/>
<link href="css/kendo.default.css" rel="stylesheet"/>
<link rel="stylesheet" type="text/css" href="css/paginador_busqueda.css"/>

<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.custom.css">
<link rel="stylesheet" type="text/css" href="css/autocomplete.css"/>
<link rel="stylesheet" type="text/css" media="screen"  href="css/calendario.css"> 
<link rel="stylesheet" type="text/css" media="screen" href="css/datePicker.css">
<link rel="stylesheet" type="text/css" href="js/fancybox/jquery.fancybox-1.3.4.css"/>
<link href="css/estilos_base.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>

<script src="js/cheques.js" language="javascript" type="text/javascript"></script>
<script src="js/kendo.core.js" language="javascript" type="text/javascript"></script>
<script src="js/kendo.numerictextbox.js" language="javascript" type="text/javascript"></script>
<script src="js/kendo.validator.js" language="javascript" type="text/javascript"></script>
<script src="js/kendo.combobox.js" language="javascript" type="text/javascript"></script>

<script src="js/fancybox/jquery.fancybox-1.3.4.pack.js" language="javascript" type="text/javascript"></script>
<script src="js/fancybox/jquery.mousewheel-3.0.4.pack.js" language="javascript" type="text/javascript"></script>

<script type="text/javascript" src="jquery-1.2.1.pack.js"></script>
<script src="js/date.js" type="text/javascript"></script>
<script src="js/jquery.datePicker.js" type="text/javascript"></script>



</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><div id="credenciales">
      <table width="100%" border="0" cellspacing="3" cellpadding="0">
        <tr>
          <td width="42"><img src="imagenes/iconos/credenciales.png" width="42" height="28" /></td>
          <td class="fuente_normal">Bienvenido : <?php echo $_SESSION['sesion_usuario'];?></td>
        </tr>
        <tr>
          <td colspan="2"><table border="0" align="center" cellpadding="0" cellspacing="3">
            <tr>
              <td><a href="cerrar_sesion.php"><img src="imagenes/iconos/salir_session.png" width="22" height="23" border="0" /></a></td>
              <td class="fuente_normal"><a href="cerrar_sesion.php">Cerrar Sessión</a></td>
              <td class="fuente_normal">|</td>
              <td class="fuente_normal"><a href="panel_principal.php"><img src="imagenes/iconos/ico_panel_principal.png" width="22" height="23" border="0" /></a></td>
              <td class="fuente_normal"><a href="panel_principal.php">Panel Principal</a></td>
            </tr>
          </table></td>
        </tr>
      </table>
    </div></td>
    <td><div id="logotipo"><img src="imagenes/logo.png" width="200" height="82" /></div></td>
    <td><table border="0" align="right" cellpadding="0" cellspacing="5">
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><span class="fuente_login">La Serena, <?php echo fecha_hoy_mas_dia();?>&nbsp;</span></td>
      </tr>
    </table></td>
  </tr>
</table>
<br />
<div id="modulo">
  <form id="form1" name="form1" method="post" action="">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="5">
      <tr>
        <td class="fuente_formularios">Fecha Cheque :</td>
        <td class="fuente_formularios"><input name="frm_fecha" type="text" class="k-textbox date-pick" id="frm_fecha" value="<?php if(isset($id)) { echo fecha_formato_espanol_gore($datos['fecha']);  } ?>" size="12"   required="required" disabled="disabled"/></td>
        <td class="fuente_formularios">&nbsp;</td>
        <td width="5" colspan="2" class="fuente_formularios">&nbsp;</td>
      </tr>
     
      <tr>
        <td class="fuente_formularios">Nº Serie:</td>
        <td class="fuente_formularios"><label for="frm_serie"></label>
        <input class="k-textbox" name="frm_serie" type="text" id="frm_serie"placeholder="Ingra el Nº de Documento" required value="<?php echo $datos['n_serie']; ?>" disabled="disabled" /></td>
        <td class="fuente_formularios">Monto :</td>
        <td class="fuente_formularios"><input class="k-textbox" name="frm_monto" type="text" id="frm_monto" placeholder="Ingresa el Nº de Cuenta" required value="<?php echo $datos['monto']; ?>" disabled="disabled" /></td>
      </tr>
      <tr>
        <td class="fuente_formularios">Fecha Cobro:</td>
        <td class="fuente_formularios">
        <input name="frm_cobro" type="text" class="k-textbox date-pick" id="frm_cobro" value="<?php if(isset($id)) { echo fecha_formato_espanol_gore($datos['fecha_cobro']);  } ?>" size="12" /> 
        
    </td>
        <td class="fuente_formularios">Factura  :</td>
        <td class="fuente_formularios">
          <input type="text" name="frm_factura" id="frm_factura" class="k-textbox" size="35"  value="<?php echo $datos['n_factura']?>" required  disabled="disabled"/> 
       </td>
      </tr>
      <tr>
        <td class="fuente_formularios">Estado :</td>
        <td class="fuente_formularios">
            <select name="frm_estado" id="frm_estado">
              <option value="0" <?php if($datos['cheques_estado']==0){ ?> selected="selected" <?php } ?>>Pendiente</option>
              <option value="1" <?php if($datos['cheques_estado']==1){ ?> selected="selected" <?php } ?>>Cobrado</option>
            </select>
        </label></td>
        <td colspan="2" class="fuente_formularios">
        <?php if(isset($id)){ ?><a href="#" onclick="detalle_factura(<?php echo $datos['id_factura']; ?>);"> Ver Detalle Factura</a><?php 
		
		 	$sql_fac="select * from factura_guia where id_factura=".$datos['id_factura'];
			$r_fac=mysql_query($sql_fac);
			$fila_fac=mysql_fetch_array($r_fac);
		 ?>
         	<a href="#" onclick="detalle_guia(<?php echo $fila_fac['id_guia']; ?>);"> Ver Detalle Guia</a>
		 <?php } ?>
       </td>
      </tr>
      <?php if(isset($id)){ ?>
      <tr>
        <td colspan="5" class="fuente_formularios"><div id="mst_cheques"></div></td>
      </tr>
		<?php } ?>
      <tr>
        <td colspan="5">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="5"><center>
          <label for="oculto_id"></label>
          <input type="hidden" name="id_oculto" id="id_oculto" value="<?php echo $id;?>" />
          <?php
		    if(isset($id))
			{
			?>
            <input type="button" name="btn_modificar" id="btn_modificar" value="Modificar" class="k-button"/>
            &nbsp;&nbsp;
            <?php
			}
			?>
			<input type="button" name="btn_ingresar4" id="btn_cancelar" value="Cancelar" class="k-button"/>
        </center></td>
      </tr>
    </table>
  </form>
</div>
<br />
<div id="paginador"></div>
<script language="javascript">
$(document).ready(function(){


	
	$("#btn_modificar").click(function(){
		modificar();
	});
	$("#btn_cancelar").click(function(){
		location.href="cheques.php";
	});

	$("#paginador").html(muestra_grilla());
	
	
  	<?php  if(isset($id)){ ?>
	$("#mst_cheques").html();
	$("#proveedores").show();
	<?php } ?>
	$('.date-pick').datePicker({
	 startDate:'01/01/2000',
    clickInput:true
   }).val(<? if(!isset($id)){ ?>new Date().asString()<? }?>);
});

</script>
</body>
</html>
<?php
}
else
{
	header("Location:index.php");
}
?>